<template>
	<view>
		<view class="mt-2 container">
			<view v-if="list && list.length <= 0" class="p-2 mt-3" style="margin: 100rpx auto;">
				<u-empty mode="data" icon="http://cdn.uviewui.com/uview/empty/data.png" text="暂无展馆信息"></u-empty>
			</view>
			<view v-else>
				<view>
					<view class="top_label my-3 font_24">
						<view class="tit text-white text_hidden1 bg_main rounded_15">{{ title }}</view>
					</view>
					<view v-if="list"><company-list v-if="[list[0]].length >= 1" :list="[list[0]]" :check-types="checkTypes"></company-list></view>
					<view class="bg-white px-2 rounded_15">
						<view
							class="cont_item flex py-2"
							v-for="(child, index) of list"
							:key="child.id"
							v-if="index >= 1"
							@click="goPages('/subPages/company_home/index?id=' + child.id)"
						>
							<image v-if="!child.company_logo" class="cont_img" src="/static/img2/home/empty_logo.jpg" mode="aspectFit"></image>
							<image v-else class="cont_img" :src="child.company_logo" mode="aspectFit"></image>
							<view>
								<view class="font-weight-bold h4">{{ child.company_name }}</view>
								<view class="hot_num flex align-center font-sm">
									<view class="flex mr-2">
										<image src="/static/img2/nav1/hot_icon.png" mode=""></image>
										<text class="h6 font-weight-bold">{{ child.heat_val || 0 }}</text>
									</view>
									<text class="c_9 font_24 mr-1">展馆：{{ child.zhanguan || '暂无' }}</text>
									<!-- <text class="c_9 font_24 mr-1">展位号：{{ child.zhanwei || '暂无' }}</text> -->
									<text class="c_9 font_24 mr-1">产品数量：{{ child.company_count || 0 }}</text>
								</view>
							</view>
						</view>
					</view>
				</view>
				<u-loadmore :status="status" color="#E5E5E5" lineColor="#E5E5E5" dashed line />
			</view>
		</view>
	</view>
</template>

<script>
import { exhibiDetail } from '@/api/home/gallery.js';
import companyList from '@/components/company_list.vue';
export default {
	components: { companyList },
	data() {
		return {
			title: '',
			list: [],
			page: 1,
			status: 'loadmore',
			suo: true,
			checkTypes: 'qy'
		};
	},
	// onShow() {
	// 	this.list = [];
	// 	this.page = 1;
	// 	this.getInfo(option.id);
	// },
	onLoad(option) {
		this.getInfo(option.id);
	},
	onReachBottom() {
		if (this.suo) {
			//定义个小锁，当没有数据时锁住suo
			this.status = 'loading';
			this.page = ++this.page;
			setTimeout(() => {
				this.getInfo();
			}, 1000);
		}
	},
	methods: {
		getInfo(val) {
			let msg = {
				id: val,
				page: this.page
			};
			exhibiDetail(msg)
				.then(res => {
					this.title = res.data.title;
					this.list.push(...res.data.list);
					if (res.data.list.length == 0) {
						this.status = 'nomore';
						this.suo = false;
					} else if (res.data.list.length < 10) {
						this.status = 'nomore';
						this.suo = false;
					} else {
						this.status = 'loadmore';
						this.suo = true;
					}
				})
				.catch(err => {
					console.log('获取展馆信息失败', err);
				});
		}
	}
};
</script>

<style lang="scss" scoped>
.top_label {
	width: 100%;
	height: 56rpx;
	text-align: center;
	line-height: 56rpx;
}
.cont_item:last-child {
	border: 0;
}
.cont_item {
	border-bottom: 1px solid #d9d9d9;
	.cont_img {
		margin-right: 20rpx;
		width: 100rpx;
		height: 100rpx;
		border-radius: 10rpx;
		border: 1px solid #f2f2f2;
	}

	.hot_num {
		line-height: 42rpx;

		image {
			width: 21rpx;
			height: 26rpx;
			display: inline;
			margin-right: 5rpx;
			margin-top: 10rpx;
		}
	}
}
</style>
